package com.cankfc.controller;

import java.util.ArrayList;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cankfc.service.RoleServiceInfo;
import com.cankfc.service.UserServiceInfo;

/**
 * 
 * @author zwz
 * 
 */
@Controller
@RequestMapping("welcome.htm")
public class WelcomeController {

	private UserServiceInfo userService;
	private RoleServiceInfo roleService;

	public RoleServiceInfo getRoleService() {
		return roleService;
	}

	public void setRoleService(RoleServiceInfo roleService) {
		this.roleService = roleService;
	}

	public UserServiceInfo getUserService() {
		return userService;
	}

	public void setUserService(UserServiceInfo userService) {
		this.userService = userService;
	}

	/**
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String findAll(ModelMap model,ModelMap model2) {
		ArrayList listUser = new ArrayList();
		ArrayList listRole = new ArrayList();
		try {
			/**
			 * 首页查找所用的用户
			 */
			listUser = userService.findUser();
			listRole = roleService.findRole();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "error";
		}
		model.addAttribute("listUser", listUser);
		model2.addAttribute("listRole", listRole);
		return "welcome";
	}
}
